﻿using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.客户CRM.Service;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.流程.库存界面
{
    public partial class Form库存发运界面 : DevExpress.XtraEditors.XtraForm
    {
        private OrderCommitDTO返回 orderCommitDTO = new OrderCommitDTO返回();
        private CustomerPDTO customerPDTO = new CustomerPDTO();

        public Form库存发运界面()
        {
            InitializeComponent();
        }
        public Form库存发运界面(String barcode,String urgentFlg,String inputMobile)
        {
            InitializeComponent();
            this.orderCommitDTO = MTO订单Service.getOrderCommitDtoByBarcode(barcode);
            String mobile = this.orderCommitDTO.mobile;
            this.刷新订单信息(urgentFlg,!String.IsNullOrEmpty(inputMobile));
            if(!String.IsNullOrEmpty(inputMobile))
                this.刷新客户信息(mobile);
        }
        private void 刷新订单信息(String urgentFlg, bool bln显示电话)
        {
            if (bln显示电话) {
                this.textBox订单客户姓名.Text = this.orderCommitDTO.customerName;
                this.textBox订单电话.Text = this.orderCommitDTO.mobile;
                this.textBox订单地址.Text =
                    this.orderCommitDTO.addressProvince
                    + this.orderCommitDTO.addressCity
                    + this.orderCommitDTO.addressDistrict
                    + this.orderCommitDTO.addressDetail;
            }

            this.textBox业务类型.Text = this.orderCommitDTO.salesType;
            this.textBox是否加急 .Text = urgentFlg == "True" ? "加急" : "正常";
            this.textBox下单时间.Text = this.orderCommitDTO.orderDate.ToString();
            this.textBox坚山订单号.Text = this.orderCommitDTO.kashiyamaOrderNo;
        }
        private void 刷新客户信息(String mobile)
        {
            this.customerPDTO = CRM客户Service.getCustomerPByMobile(mobile);
            this.textBox客户姓名.Text = this.customerPDTO.customerName;
            this.textBox客户电话.Text = this.customerPDTO.mobile;
            this.textBox客户地址.Text =
                this.customerPDTO.addressProvince
                + this.customerPDTO.addressCity
                + this.customerPDTO.addressDistrict
                + this.customerPDTO.addressDetail;
        }
    }
}
